package utils;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;

import android.content.Context;
import android.content.Intent;

public class ShowException {

    public static void show(Context packageContext, Exception e) {

	Intent intent = new Intent(packageContext,
		test.views.ExceptionView.class);
	intent.putExtra("exception", getStackTrace(e));
	packageContext.startActivity(intent);
    }
    
    public static void showMessage(Context packageContext, String message) {
	
	Intent intent = new Intent(packageContext,
		test.views.ExceptionView.class);
	intent.putExtra("exception", message);
	packageContext.startActivity(intent);
    }

    public static String getStackTrace(Throwable aThrowable) {
	final Writer result = new StringWriter();
	final PrintWriter printWriter = new PrintWriter(result);
	aThrowable.printStackTrace(printWriter);
	return result.toString();
    }
}
